package com.lecyon.farm.vo.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lecyon.farm.common.constant.CommonConstant;
import com.lecyon.farm.util.StringHelper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * 基础查询vo
 *
 * @author Yao Zheng
 */
@Data
public class BaseQueryVo extends QueryWrapper implements Serializable {

    @ApiModelProperty(name = "del_flag", value = "逻辑删除标记，默认为0")
    private String delFlag = CommonConstant.DEL_FLAG_UNDELETED;

    @ApiModelProperty(name = "customCondition", value = "用户自定义查询条件")
    private String customCondition;

    @ApiModelProperty(name = "数据crt_user_id", value = "用于数据隔离")
    private Long crtUserId;

    @ApiModelProperty(name = "userToken", value = "用于数据隔离与鉴权", required = true)
    @NotBlank(message = "令牌不能为空")
    protected String userToken;

    /**
     * 自定义查询字段
     *
     * @return
     */
    public String getCustomCondition() {
        return StringHelper.isEmpty(customCondition) ? null : customCondition;
    }
}
